package com.endurance.gateway.filter.factory;

import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.factory.AbstractNameValueGatewayFilterFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @ProjectName: spring-cloud-hoxton-parent
 * @Package: com.endurance.gateway.filter.factory
 * @ClassName: MultiValueGatewayFilterFactory
 * @Description:
 * @Author: sunlin
 * @CreateDate: 2024/02/12 14:40
 * @Version: 1.0
 */

@Component
public class MultiValueGatewayFilterFactory extends AbstractNameValueGatewayFilterFactory {

    @Override
    public GatewayFilter apply(NameValueConfig config) {
        return new GatewayFilter() {
            @Override
            public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
                String name = config.getName();
                String value = config.getValue();
                System.out.println("name:" + name);
                System.out.println("value:" + value);
                return chain.filter(exchange);
            }
        };
    }

}
